package com.newtouch.bxzs.business.personal.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.newtouch.bxzs.business.config.MyLog;
import com.newtouch.bxzs.business.personal.model.PartnersBO;
import com.newtouch.bxzs.business.personal.model.PartnersDetailBO;
import com.newtouch.bxzs.business.personal.service.PartnersService;
import com.newtouch.bxzs.common.base.response.BaseResponse;
import com.newtouch.bxzs.common.base.response.RespGenerator;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 合作伙伴Controller类
 *
 * <table border="1">
 * <tr>
 * <th>Date</th>
 * <th>Operator</th>
 * <th>Memo</th>
 * </tr>
 * <tr>
 * <td>2021/1/18 14:32</td>
 * <td>田尚柱</td>
 * <td>Create</td>
 * </tr>
 * </table>
 *
 * @author 田尚柱
 * @version 1.0.0
 */

@Api(tags = "查询合作伙伴")
@RestController
@SuppressWarnings("unchecked")
@RequestMapping("/partnersController")
public class PartnersController {
    @Resource
    private PartnersService partnersService;

    /**
     * 静态变量：日志
     */
    private static final Log logger = LogFactory.getLog(PartnersController.class);

    @ApiOperation("获取合作伙伴列表")
    @ApiImplicitParam(name = "currentPage", value = "当前页", dataType = "Integer", required = true)
    @GetMapping("/getPartnersList")
    @MyLog(systemFunctionName = "查询合作伙伴", systemFunctionUrl = "/partnersController/getPartnersList", userOperationType = 4, userOperationSummary = "获取合作伙伴列表")
    public BaseResponse<IPage<PartnersBO>> getPartnersList(@RequestParam(value = "currentPage") Integer currentPage,@RequestParam(value = "tagFlag") Integer tagFlag){
        logger.info("开始查询合作伙伴");
        return RespGenerator.returnOK(partnersService.getPartnersList(currentPage,tagFlag));
    }

    @ApiOperation("获取合作伙伴详情")
    @ApiImplicitParam(name = "cooperationCompanyUserId", value = "合作公司用户ID", dataType = "String", required = true)
    @GetMapping("/getPartnersDetail")
    @MyLog(systemFunctionName = "查询合作伙伴", systemFunctionUrl = "/partnersController/getPartnersDetail", userOperationType = 4, userOperationSummary = "查询合作伙伴接口")
    public BaseResponse<PartnersDetailBO> getPartnersDetail(@RequestParam(value = "cooperationCompanyUserId") String cooperationCompanyUserId,@RequestParam(value = "tagFlag") Integer tagFlag){
        logger.info("开始查询合作伙伴详情");
        return RespGenerator.returnOK(partnersService.getPartnersDetail(cooperationCompanyUserId,tagFlag));
    }
}
